package com.it.mapper;

import com.it.pojo.dto.RegisterDTO;
import com.it.pojo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    /**
     * 根据用户名查询用户
     * @param username
     * @return
     */
    @Select("select * from users where username = #{username}")
    User getByUsername(String username);

    /**
     * 添加用户
     * @param registerDTO
     */
    @Select("insert into users (username, password) values (#{username}, #{password})")
    void add(RegisterDTO registerDTO);

    /**
     * 根据用户ID查询用户
     * @param userId
     * @return
     */
    @Select("select * from users where id = #{id}")
    User getById(Long userId);
}
